package biz.obake.team.touchprotector.tpservice;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.media.AudioAttributes;
import android.net.Uri;
import android.os.Build;
import biz.obake.team.touchprotector.R;
import biz.obake.team.touchprotector.StaticReceiver;
import biz.obake.team.touchprotector.g.c;
import biz.obake.team.touchprotector.ui.MainActivity;

public class a {

    /* renamed from: a  reason: collision with root package name */
    private TPService f1805a;

    public a(TPService tPService) {
        this.f1805a = tPService;
        g();
    }

    /* JADX WARNING: Can't fix incorrect switch cases order */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private void a(android.app.Notification.Builder r9) {
        /*
            r8 = this;
            java.lang.String r0 = "action_buttons"
            java.lang.String r1 = biz.obake.team.touchprotector.g.a.l(r0)
            int r2 = r1.hashCode()
            java.lang.String r3 = "sensor_settings"
            r4 = 4
            r5 = 3
            r6 = 2
            r7 = 1
            switch(r2) {
                case -368905197: goto L_0x0030;
                case 3387192: goto L_0x0026;
                case 502344456: goto L_0x001e;
                case 1527827380: goto L_0x0014;
                default: goto L_0x0013;
            }
        L_0x0013:
            goto L_0x003a
        L_0x0014:
            java.lang.String r2 = "sensor_quit"
            boolean r1 = r1.equals(r2)
            if (r1 == 0) goto L_0x003a
            r1 = 2
            goto L_0x003b
        L_0x001e:
            boolean r1 = r1.equals(r3)
            if (r1 == 0) goto L_0x003a
            r1 = 1
            goto L_0x003b
        L_0x0026:
            java.lang.String r2 = "none"
            boolean r1 = r1.equals(r2)
            if (r1 == 0) goto L_0x003a
            r1 = 4
            goto L_0x003b
        L_0x0030:
            java.lang.String r2 = "quit_settings"
            boolean r1 = r1.equals(r2)
            if (r1 == 0) goto L_0x003a
            r1 = 3
            goto L_0x003b
        L_0x003a:
            r1 = -1
        L_0x003b:
            if (r1 == r7) goto L_0x0052
            if (r1 == r6) goto L_0x004b
            if (r1 == r5) goto L_0x0047
            if (r1 == r4) goto L_0x0058
            biz.obake.team.touchprotector.g.a.r(r0, r3)
            goto L_0x0052
        L_0x0047:
            r8.c(r9)
            goto L_0x0055
        L_0x004b:
            r8.d(r9)
            r8.c(r9)
            goto L_0x0058
        L_0x0052:
            r8.d(r9)
        L_0x0055:
            r8.e(r9)
        L_0x0058:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: biz.obake.team.touchprotector.tpservice.a.a(android.app.Notification$Builder):void");
    }

    private void b(Notification.Builder builder) {
        builder.setSmallIcon(c.b("Sensors.Paused") ? R.drawable.ic_stat_notify_pause : R.drawable.ic_stat_notify);
    }

    private void c(Notification.Builder builder) {
        Intent intent = new Intent(this.f1805a, StaticReceiver.class);
        intent.setAction("biz.obake.team.touchprotector.quit");
        builder.addAction(R.drawable.ic_stat_notify, biz.obake.team.touchprotector.c.w(R.string.menu_quit), PendingIntent.getBroadcast(this.f1805a, 0, intent, 268435456));
    }

    private void d(Notification.Builder builder) {
        int i;
        Intent intent;
        if (c.b("Sensors.Paused")) {
            intent = new Intent(this.f1805a, StaticReceiver.class);
            intent.setAction("biz.obake.team.touchprotector.resume_sensor");
            i = R.string.menu_resume_sensor;
        } else {
            intent = new Intent(this.f1805a, StaticReceiver.class);
            intent.setAction("biz.obake.team.touchprotector.pause_sensor");
            i = R.string.menu_pause_sensor;
        }
        builder.addAction(R.drawable.ic_stat_notify, biz.obake.team.touchprotector.c.w(i), PendingIntent.getBroadcast(this.f1805a, 0, intent, 268435456));
    }

    private void e(Notification.Builder builder) {
        builder.addAction(17301577, biz.obake.team.touchprotector.c.w(R.string.menu_settings), PendingIntent.getActivity(this.f1805a, 0, new Intent(this.f1805a, MainActivity.class), 268435456));
    }

    private Notification f() {
        boolean equals = "Locked".equals(c.c("TPService.State"));
        int i = equals ? R.string.notify_protecting_text : R.string.notify_waiting_text;
        Notification.Builder ongoing = new Notification.Builder(this.f1805a).setOngoing(true);
        b(ongoing);
        if (!equals) {
            Intent intent = new Intent(this.f1805a, StaticReceiver.class);
            intent.setAction("biz.obake.team.touchprotector.notification");
            ongoing.setContentIntent(PendingIntent.getBroadcast(this.f1805a, 0, intent, 268435456));
        }
        if (Build.VERSION.SDK_INT < 24) {
            ongoing.setContentTitle(biz.obake.team.touchprotector.c.w(R.string.app_name)).setContentText(biz.obake.team.touchprotector.c.w(i));
        } else {
            ongoing.setContentTitle(biz.obake.team.touchprotector.c.w(i));
        }
        if (Build.VERSION.SDK_INT >= 26) {
            ongoing.setChannelId("default");
        }
        a(ongoing);
        return ongoing.build();
    }

    private void g() {
        NotificationManager notificationManager;
        if (Build.VERSION.SDK_INT >= 26 && (notificationManager = (NotificationManager) this.f1805a.getSystemService("notification")) != null) {
            NotificationChannel notificationChannel = new NotificationChannel("default", biz.obake.team.touchprotector.c.w(R.string.notif_channel_name), 3);
            notificationChannel.setShowBadge(false);
            notificationChannel.setSound((Uri) null, (AudioAttributes) null);
            notificationManager.createNotificationChannel(notificationChannel);
        }
    }

    public void h() {
        this.f1805a.startForeground(1, f());
    }

    public void i() {
        NotificationManager notificationManager = (NotificationManager) this.f1805a.getSystemService("notification");
        if (notificationManager != null) {
            notificationManager.notify(1, f());
        }
    }
}
